<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./template/StakeholderTemplate.xhtml">
    <ui:define name="begin">
        <f:view beforePhase="#{mealManagerBean.initUpdateSetMeal}"/>
    </ui:define>
   <ui:define name="contentInsert"> 
    <h:body>
        <h:form id="formMain">
            <p:panel id="panel" header="Update Set Meal">
                <p:ajaxStatus style="width:16px;height:16px;">
                    <f:facet name="start">
                        <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                    </f:facet>
                    <f:facet name="complete">
                        <h:outputText value="" />
                    </f:facet>
                </p:ajaxStatus>
                <p:messages/>

                <h:panelGrid  >

                    <f:metadata>
                        <f:viewParam name ="visibility" value ="#{mealManagerBean.selectedSetMeal.visibility}" />
                    </f:metadata>
                    <p:ajaxStatus style="width:16px;height:16px;">
                        <f:facet name="start">
                            <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                        </f:facet>
                        <f:facet name="complete">
                            <h:outputText value="" />
                        </f:facet>
                    </p:ajaxStatus>
                    <p:messages />


                    <h:outputLabel for="setMealName" style="font-weight: bold" value="Set Meal Name: " />
                    <h:inputText id="setMealName" value="#{mealManagerBean.selectedSetMeal.name}">
                    </h:inputText>
                    <p:message for="setMealName" />


                    <h:outputLabel for="originalPrice" style="font-weight: bold" value="Original Price: " />
                    <h:inputText id="originalPrice" value="#{mealManagerBean.selectedSetMeal.originalPrice}">
                    </h:inputText>
                    <p:message for="originalPrice" />

                    <h:outputLabel for="description" style="font-weight: bold" value="Description: " />
                    <h:inputText id="description" value="#{mealManagerBean.selectedSetMeal.description}">
                    </h:inputText>
                    <p:message for="description" />

                    <h:outputLabel for="visisbility" style="font-weight: bold" value="Visible to Customers: " />
                    <h:outputText id="visisbility" value="#{mealManagerBean.selectedSetMeal.visibility}">
                    </h:outputText>
                    <p:message for="visisbility" />                  
                    <p:button value="Enable" disabled="#{mealManagerBean.selectedSetMeal.visibility}" outcome="StakeholderUpdateSelectedSetMeal">
                        <f:param name="visibility" value="true" />
                    </p:button>
                    <p:button value="Disable" disabled="#{!mealManagerBean.selectedSetMeal.visibility}" outcome="StakeholderUpdateSelectedSetMeal">
                        <f:param name="visibility" value="false" />
                    </p:button>

                   
                    <h:outputLabel for="image" style="font-weight: bold" value="Set Meal Image: " />
                    <h:graphicImage id="gi" alt="The image could not be found."   value="/images/#{mealManagerBean.selectedSetMeal.imageLink}" width="250" height="250"></h:graphicImage>
                    
                    <p:fileUpload id="upload" fileUploadListener="#{mealManagerBean.handleImageUploadSetMeal}" 
                                  allowTypes="*.jpg;*.png;*.gif;" description="Images" update ="msg gi"/>     
                    <p:growl id="msg" />
                    <p:dataTable var="mealList" value="#{mealManagerBean.mealOfBranch}" selection="#{mealManagerBean.selectedMeals_update}" paginator="true" rows="10">
                        <p:column selectionMode="multiple" />

                        <p:column sortBy="#{mealList.name}" filterBy="#{mealList.name}">  
                            <f:facet name="header">  
                                <h:outputText value="Meal Name" />  
                            </f:facet>  
                            <h:outputText value="#{mealList.name}" />  
                        </p:column>  

                        <p:column sortBy="#{mealList.description}" filterBy="#{mealList.description}">  
                            <f:facet name="header">  
                                <h:outputText value="Description" />  
                            </f:facet>  
                            <h:outputText value="#{mealList.description}" />  
                        </p:column>  
                        
                        <p:column sortBy="#{mealList.type.name}" filterBy="#{mealList.type.name}">  
                            <f:facet name="header">  
                                <h:outputText value="Type" />  
                            </f:facet>  
                            <h:outputText value="#{mealList.type.name}" />  
                        </p:column> 
                    </p:dataTable>

                </h:panelGrid>
                <br/>
                 <p:commandButton id="btn1" value="Save Set Meal Update" update="panel" actionListener="#{mealManagerBean.updateSetMeal}" ajax="true" />
                 <p:commandButton id="btn2" value="Delete Set Meal" update="panel" actionListener="#{mealManagerBean.deleteSetMeal}" ajax="true" />
            </p:panel>
        </h:form>
    </h:body>
    </ui:define>
</ui:composition>